#include "./SkillButtonUI.j"
#include "./SkillButtonVo.j"
#include "./SkillVo.j"

// 技能随机系统
library RandomSkillSys initializer init requires SkillVo

    // 选择技能
    function selectSkill takes integer uid, integer bigSkillId, integer smallSkillId returns nothing

        local integer btnId
        local integer v

        call addSmallSkillStudyCount(uid, bigSkillId, smallSkillId)
        // 飞剑术
        if bigSkillId == 1 then
            // 设置CD
            set btnId = getSkillButtonId(uid, bigSkillId)
            // 进行是CD
            // 因为没多一个连放需要0.5秒，连放结束再进行CD
            // call setSkillButtonStartingCD(btnId, 0.5 * ct_flyAttCount[uid])
            // 释放完CD
            // call setSkillButtonEndingCD(btnId, 1.5)

            set ct_flyLevel[uid] = ct_flyLevel[uid] + 1
            // 飞剑数量 +1
            if smallSkillId == 1 then
                set ct_flyCount[uid] = ct_flyCount[uid] + 1
            elseif smallSkillId == 2 then
                set v = GetRandomInt(20, 80)
                set ct_flyDmZf[uid] = ct_flyDmZf[uid] + I2R(v) / 100.0
                call sendMessage(uid, 0, "飞剑伤害增幅+" + I2S(v) + "%")
            elseif smallSkillId == 3 then
                set ct_flyBoom[uid] = true
            elseif smallSkillId == 4 then
                set v = GetRandomInt(20, 60)
                set ct_flyBoomRangZf[uid] = ct_flyBoomRangZf[uid] + I2R(v) / 100.0
                call sendMessage(uid, 0, "飞剑爆炸范围增幅+" + I2S(v) + "%")
            elseif smallSkillId == 5 then
                set v = GetRandomInt(20, 60)
                set ct_flyBoomDmZf[uid] = ct_flyBoomDmZf[uid] + I2R(v) / 100.0
                call sendMessage(uid, 0, "飞剑爆炸伤害增幅+" + I2S(v) + "%")
            elseif smallSkillId == 6 then
                set ct_flyPzCount[uid] = ct_flyPzCount[uid] + 1
            elseif smallSkillId == 7 then
                set ct_flyFire[uid] = true
            elseif smallSkillId == 8 then
                set v = GetRandomInt(20, 80)
                set ct_flyFireDmZf[uid] = ct_flyFireDmZf[uid] + I2R(v) / 100.0
                call sendMessage(uid, 0, "火焰飞剑伤害增幅+" + I2S(v) + "%")
            elseif smallSkillId == 9 then
                set v = GetRandomInt(300, 1000)
                set ct_flyDistance[uid] = ct_flyDistance[uid] + I2R(v)
                call sendMessage(uid, 0, "飞剑距离+" + I2S(v))
            elseif smallSkillId == 10 then
                set ct_flyAttCount[uid] = ct_flyAttCount[uid] + 1
                // 进行是CD
                // 因为没多一个连放需要0.5秒，连放结束再进行CD
                call setSkillButtonStartingCD(uid, btnId, 0.5 * ct_flyAttCount[uid])
            endif
        // 火焰弹
        elseif bigSkillId == 2 then
            set btnId = getSkillButtonId(uid, bigSkillId)
            // 火焰弹等级
            set ct_hydLevel[uid] = ct_hydLevel[uid] + 1
            if smallSkillId == 1 then
                call newSkillButton(uid, bigSkillId, "BTNicofjs2.blp", 0, ct_hydCD[uid])
                call sendMessage(uid, 0, "解锁了[|cff00ff00火焰弹|r]")
            elseif smallSkillId == 2 then
                set ct_hydDmgZf[uid] = ct_hydDmgZf[uid] + 0.8
            elseif smallSkillId == 3 then
                set ct_hydAttCount[uid] = ct_hydAttCount[uid] + 1

                // 进行是CD
                // 因为没多一个连放需要0.5秒，连放结束再进行CD
                call setSkillButtonStartingCD(uid, btnId, 0.5 * ct_hydAttCount[uid])
            elseif smallSkillId == 4 then
                set ct_hydBoomRangZf[uid] = ct_hydBoomRangZf[uid] + 0.2
            elseif smallSkillId == 5 then
                set ct_hydBoomDmgZf[uid] = ct_hydBoomDmgZf[uid] + 0.4
            endif

        // 掌心雷
        elseif bigSkillId == 3 then
            set btnId = getSkillButtonId(uid, bigSkillId)
            // 等级
            set ct_zxlLevel[uid] = ct_zxlLevel[uid] + 1
            if smallSkillId == 1 then
                call newSkillButton(uid, bigSkillId, "BTNicofjs3.blp", 0, ct_zxlCD[uid])
                call sendMessage(uid, 0, "解锁了[|cff00ff00掌心雷|r]")
            elseif smallSkillId == 2 then
                set ct_zxlBoomRangZf[uid] = ct_zxlBoomRangZf[uid] + 0.2
            elseif smallSkillId == 3 then
                set ct_zxlBoomDmgZf[uid] = ct_zxlBoomDmgZf[uid] + 0.4
            elseif smallSkillId == 4 then
                set ct_zxlAttCount[uid] = ct_zxlAttCount[uid] + 1
                // 进行是CD
                // 因为没多一个连放需要0.5秒，连放结束再进行CD
                call setSkillButtonStartingCD(uid, btnId, 0.5 * ct_zxlAttCount[uid])
            elseif smallSkillId == 5 then
                set ct_zxlIsMB[uid] = true
            elseif smallSkillId == 6 then
                set ct_zlxMbRate[uid] = ct_zlxMbRate[uid] + 0.1
            elseif smallSkillId == 7 then
                set ct_zlxMBLevel[uid] = ct_zlxMBLevel[uid] + 1
            endif
        // 闪电链
        elseif bigSkillId == 4 then
            set btnId = getSkillButtonId(uid, bigSkillId)
            // 等级
            set ct_sdlLevel[uid] = ct_sdlLevel[uid] + 1
            if smallSkillId == 1 then
                call newSkillButton(uid, bigSkillId, "BTNicofjs3.blp", 0, ct_sdlCD[uid])
                call sendMessage(uid, 0, "解锁了[|cff00ff00闪电链|r]")
            elseif smallSkillId == 2 then
                set ct_sdlDmgZf[uid] = ct_sdlDmgZf[uid] + 0.3
            elseif smallSkillId == 3 then
                set ct_sdlMzCount[uid] = ct_sdlMzCount[uid] + 1
            elseif smallSkillId == 4 then
                set ct_sdlIsChixu[uid] = true
            elseif smallSkillId == 5 then
                set ct_sdlCXDmgZf[uid] = ct_sdlCXDmgZf[uid] + 0.3
            elseif smallSkillId == 6 then
                set ct_sdlCXCount[uid] = ct_sdlCXCount[uid] + 1
            endif
        // 寒冰箭
        elseif bigSkillId == 5 then
            set btnId = getSkillButtonId(uid, bigSkillId)
            // 等级
            set ct_hbjLevel[uid] = ct_hbjLevel[uid] + 1
            if smallSkillId == 1 then
                call newSkillButton(uid, bigSkillId, "BTNicofjs3.blp", 0, ct_hbjCD[uid])
                call sendMessage(uid, 0, "解锁了[|cff00ff00寒冰箭|r]")
            elseif smallSkillId == 2 then
                set ct_hbjDmZf[uid] = ct_hbjDmZf[uid] + 0.3
            elseif smallSkillId == 3 then
                set ct_hbjRDis[uid] = ct_hbjRDis[uid] + 300.0
            elseif smallSkillId == 4 then
                set ct_hbjCount[uid] = ct_hbjCount[uid] + 1
                // 进行是CD
                // 因为没多一个连放需要0.5秒，连放结束再进行CD
                call setSkillButtonStartingCD(uid, btnId, 0.5 * ct_hbjCount[uid])
            elseif smallSkillId == 5 then
                set ct_hbjDongj[uid] = true
            elseif smallSkillId == 6 then
                set ct_hbjDongjLevel[uid] = ct_hbjDongjLevel[uid] + 1
            elseif smallSkillId == 7 then
                set ct_hbjIsJS[uid] = true
            elseif smallSkillId == 8 then
                set ct_hbjJSLevel[uid] = ct_hbjJSLevel[uid] + 1
            elseif smallSkillId == 9 then
                set ct_hbjIsDS[uid] = true
            elseif smallSkillId == 10 then
                set ct_hbjDSDmgZf[uid] = ct_hbjDSDmgZf[uid] + 0.5
            elseif smallSkillId == 11 then
                set ct_hbjDSCount[uid] = ct_hbjDSCount[uid] + 2
            elseif smallSkillId == 12 then
                set ct_hbjPzCount[uid] = ct_hbjPzCount[uid] + 1
            elseif smallSkillId == 13 then
                set ct_hbjIsBoom[uid] = true
            elseif smallSkillId == 14 then
                set ct_hbjBoomCount[uid] = ct_hbjBoomCount[uid] + 1
            elseif smallSkillId == 15 then
                set ct_hbjBoomDmgZf[uid] = ct_hbjBoomDmgZf[uid] + 0.5
            elseif smallSkillId == 16 then
                set ct_hbjBoomDJ[uid] = true
            elseif smallSkillId == 17 then
                set ct_hbjBoomDJLevel[uid] = ct_hbjBoomDJLevel[uid] + 1
            elseif smallSkillId == 18 then
                set ct_hbjBoomJS[uid] = true
            elseif smallSkillId == 19 then
                set ct_hbjBoomJSLevel[uid] = ct_hbjBoomJSLevel[uid] + 1
            elseif smallSkillId == 20 then
                set ct_hbjBoomIsDS[uid] = true
            endif
        endif
    endfunction

    private function init takes nothing returns nothing

        
    endfunction

    
endlibrary

